//
//  AnimationView.m
//  vmcshop
//
//  Created by toggle on 15/4/21.
//  Copyright (c) 2015年 idongler. All rights reserved.
//

#import "AnimationView.h"

@implementation AnimationView

- (id)initWithFrame:(CGRect)frame {
	self = [super initWithFrame:frame];
	if (self) {
		[self jiaZai];
		self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
		self.layer.masksToBounds = YES;
		self.layer.cornerRadius = 4;
	}
	
	return self;
}

-(void)jiaZai
{
	
	self.imageIcon = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 20, 20)];
	[self addSubview:self.imageIcon];
	
	UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(25, 5, 100, 20)];
	label.font = [UIFont systemFontOfSize:12];
	label.textColor = [UIColor whiteColor];
	
	label.text = @"加载中,请稍后...";
	[[NSString string] sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.0f]}];
	[self addSubview:label];
	
	
	NSMutableArray *arr = [[NSMutableArray alloc]init];
	for (int i = 0; i < 4; i++) {
		NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"logoAnimation%d",i+1] ofType:@"png"];
		UIImage *img = [UIImage imageWithContentsOfFile:path];
		[arr addObject:img];
	}
	[self.imageIcon setAnimationImages:arr];
	[self.imageIcon setAnimationDuration:0.5];
	[self.imageIcon startAnimating];
}

- (void)layoutSubviews
{
	[super layoutSubviews];
}

@end
